/*
 * Created by pan 2018/11/5
 */
const express = require('express');
const router = express.Router();
const superagent = require('superagent');

const fetchData = (type = 'jx') => {
    return new Promise(resolve => {
        resolve(
            superagent.get(
                `https://b.zhuishushenqi.com/category/group-minlist?node=e5fe6058afa449e4a8b9b3fb843c2bcd&sex=male&token=&userId=&cv=&groupid=&pl=ios&type=${type}&appType=&packageName=`
            )
        );
    });
};

router.get('/', async function(req, res, next) {
    const result = await fetchData(req.query.type);
    try {
        res.json(result.body);
    } catch (e) {
        res.json({
            result: 0,
            message: e.toString(),
        });
    }
});
module.exports = router;
